/*************************************************************************
 *
 *   file		: Duel.cs
 *   copyright		: (C) The WCell Team
 *   email		: info@wcell.org
 *   last changed	: $LastChangedDate: 2009-03-07 06:58:12 +0000 (Sat, 07 Mar 2009) $
 *   last author	: $LastChangedBy: ralekdev $
 *   revision		: $Rev: 784 $
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *************************************************************************/

using WCell.Constants;
using WCell.Constants.Spells;
using WCell.RealmServer.Entities;
using WCell.RealmServer.Misc;

namespace WCell.RealmServer.Spells.Effects
{
	/// <summary>
	/// The caster requests a duel with the given target.
	/// Only used in: Duel (Id: 7266) (non-displayed Skill)
	/// </summary>
	public class DuelEffectHandler : SpellEffectHandler
	{
		public DuelEffectHandler(SpellCast cast, SpellEffect effect)
			: base(cast, effect)
		{
		}

		public override void Initialize(ref SpellFailedReason failReason)
		{
			var rival = m_cast.Selected as Character;
			if (rival != null)
			{
				failReason = Duel.CheckRequirements(m_cast.CasterChar, rival);
			}
		}

		public override bool HasOwnTargets
		{
			get
			{
				return false;
			}
		}

		public override void Apply()
		{
			Duel.InitializeDuel(m_cast.CasterChar, m_cast.Selected as Character);
		}

		public override ObjectTypes CasterType
		{
			get
			{
				return ObjectTypes.Player;
			}
		}

		public override ObjectTypes TargetType
		{
			get
			{
				return ObjectTypes.Player;
			}
		}
	}
}
